package CtrlLayer;
import ModelLayer.*;
import java.util.Calendar;

/**
 * Write a description of class OrdreCtrl here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class OrdreCtrl
{
    private KundeCtrl kundeCtrl;
    private VareCtrl vareCtrl;
    private OrdreContainer ordreContainer;
    private Ordre o;
    private Delordre d;
    private Kunde k;
    private Vare v;
    private Calendar c;
    
    /**
     * Constructor for objects of class OrdreCtrl
     */
    public OrdreCtrl()
    {
        kundeCtrl = new KundeCtrl();
        vareCtrl = new VareCtrl();
        ordreContainer = ordreContainer.getInstance();
        c = c.getInstance();
    }

    /**
     * 
     */
    public void opretOrdre()
    {
        o = new Ordre();
    }
    
    /**
     * 
     */
    public String findOrdre(int id)
    {
        String print = ordreContainer.findOrdre(id).toString();
        return print;
    }
    
    /**
     * 
     */
    public String findKunde(String nr)
    {
        k = kundeCtrl.findKunde(nr);
        return k.toString();
    }
    
    /**
     * 
     */
    public String findVare(String navn, int antal)
    {
        v = vareCtrl.findVare(navn, antal);
        return v.toString();
    }
    
    /**
     * 
     */
    public void addDelordre()
    {
        d = new Delordre(v);
        o.addDelordre(d);
    }
    
    /**
     * 
     */
    public void registrerOrdre()
    {
        o.setKunde(k);
        o.setTotalpris();
        o.setKøbsdato(c.get(c.DAY_OF_MONTH), c.get(c.MONTH) + 1, c.get(c.YEAR));
		o.setLeveringsaddresse(null);
        ordreContainer.addOrdre(o);
    }
    
    /**
     * 
     */
    public void deleteOrdre(int id)
    {
        ordreContainer.deleteOrdre(id);
    }
}
